package org.apache.james.spring2;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.apache.james.core.MimeMessageWrapper;
import org.apache.james.imapserver.store.SimpleMessageAttributes;

public class MsgAttrTest {

	/**
	 * @param args
	 * @throws MessagingException 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws MessagingException, IOException {
		// TODO Auto-generated method stub
		MimeMessage msg = new MimeMessage(null, new BufferedInputStream(new FileInputStream("test/testmail.txt")));
		
		SimpleMessageAttributes attr = new SimpleMessageAttributes(msg);
		System.out.println("envelope:'"+attr.getEnvelope()+"'");
		System.out.println("body structure:'"+attr.getBodyStructure(false)+"'");
		System.out.println("body structure:'"+attr.getBodyStructure(true)+"'");
		
		//msg.writeTo(new FileOutputStream("test/header.txt"), new FileOutputStream("test/body.txt"));
		
		MimeMessageWrapper mmw = new MimeMessageWrapper(msg);
		mmw.writeTo(new FileOutputStream("test/header.txt"), new FileOutputStream("test/body.txt"));
	}

}
